<template>
  <div>
    <div class="repaymentQuery" v-if="show_query">
      <el-form label-width="100px" label-position="right">
        <el-row :span="20">
          <el-col :span="10">
            <el-form-item label="户名：">
              <el-input
                style="width: 120px"
                v-model="objForm.hm"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="证件号码：">
              <el-input
                style="width: 120px"
                v-model="objForm.idNo"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :span="20">
          <el-col :span="10">
            <el-form-item label="贷款合同号：">
              <el-input
                style="width: 120px"
                v-model="objForm.contNo"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="借据号：">
              <el-input
                style="width: 120px"
                v-model="objForm.loanNo"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="放款日期：">
              <el-date-picker
                v-model="objForm.loanActvDt"
                type="datetimerange"
                range-separator="-"
                start-placeholder=""
                end-placeholder=""
                style="width: 250px"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-form-item style="padding-top: 20px; float: left; width: 76px">
            <el-button type="primary" @click="queryInfo" size="large"
              >查询</el-button
            >
          </el-form-item>
          <el-form-item style="padding-top: 20px; width: 76px; float: left">
            <el-button type="primary" @click="restAll" size="large"
              >重置</el-button
            >
          </el-form-item>
        </el-row>
      </el-form>

      <el-table
        :data="repaymentQueryData"
        title="还款信息查询列表"
        border
        height="300"
        stripe="true"
        style="width: 150%"
      >
        <!-- <el-table-column label="序号" width="50" type="index" /> -->
        <el-table-column
          prop="contNo"
          label="贷款合同号"
          width="120"
          align="center"
        />
        <el-table-column
          prop="loanNo"
          label="贷款借据号"
          width="120"
          align="center"
        />
        <el-table-column
          prop="custName"
          label="客户名称"
          width="120"
          align="center"
        />
        <el-table-column
          prop="idNo"
          label="证件号码"
          width="120"
          align="center"
        />
        <el-table-column
          prop="origPrcped"
          label="放款金额"
          width="120"
          align="center"
        />
        <el-table-column
          prop="applyTnr"
          label="贷款期限"
          width="120"
          align="center"
        />
        <el-table-column
          prop="loanActvDt"
          label="放款日期"
          width="120"
          align="center"
        />
        <el-table-column
          prop="sfwchjj"
          label="是否为偿还借据"
          width="120"
          align="center"
        />
        <el-table-column label="操作" width="120" align="center">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="primary"
              @click="handleRepaymentInitiative(scope.$index, scope.row)"
              >主动还款</el-button
            >
          </template>
        </el-table-column>
        <el-table-column label="操作" width="120" align="center">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="primary"
              @click="handleRepaymentScheduled(scope.$index, scope.row)"
              >预约还款</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <!-- <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="currentPage"
          :page-sizes="[10, 20, 30, 40,50]"
          :page-size="10"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
          style="float: right;">
        </el-pagination> -->
    </div>

    <div class="repaymentInitiative" v-if="show_repaymentInitiative">
      <!-- 主动还款页面 -->
      <span style="color: black; font-size: 20px; padding-top: 0; float: left"
        >基本信息</span
      >
      <el-divider />

      <el-form
        label-width="140px"
        label-position="right"
        style="padding-left: 10px"
      >
        <el-row :span="20">
          <el-col :span="10">
            <el-form-item label="贷款合同号：">
              <el-input
                style="width: 160px"
                v-model="objForm_initiative.contNo"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="贷款借据号：">
              <el-input
                style="width: 160px"
                v-model="objForm_initiative.loanNo"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :span="20">
          <el-col :span="10">
            <el-form-item label="客户姓名：">
              <el-input
                style="width: 160px"
                v-model="objForm_initiative.custName"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="证件类型：">
              <el-select
                v-model="objForm_initiative.idTyp"
                placeholder=""
                style="width: 160px"
              >
                <el-option
                  v-for="item in zjlx1Options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :span="20">
          <el-col :span="10">
            <el-form-item label="证件号码：">
              <el-input
                style="width: 160px"
                v-model="objForm_initiative.idNo"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="放款金额：">
              <el-input
                style="width: 160px"
                v-model="objForm_initiative.origPrcped"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :span="20">
          <el-col :span="10">
            <el-form-item label="剩余本金：">
              <el-input
                style="width: 160px"
                v-model="objForm_initiative.sybj"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="执行年利率：">
              <el-input
                style="width: 160px"
                v-model="objForm_initiative.loanIntRate"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :span="20">
          <el-col :span="10">
            <el-form-item label="溢缴款余额：">
              <el-input
                style="width: 160px"
                v-model="objForm_initiative.yjkye"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

      <span style="color: black; font-size: 20px; padding-top: 0; float: left"
        >主动还款信息</span
      >
      <el-divider />
      <el-form
        label-width="140px"
        label-position="right"
        style="padding-left: 10px"
      >
        <el-row :span="20">
          <el-col :span="10">
            <el-form-item label="还款模式：">
              <el-select
                v-model="objForm_initiative.hkms"
                placeholder=""
                style="width: 160px"
              >
                <el-option
                  v-for="item in hkms1Options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="费用总金额：">
              <el-input
                style="width: 160px"
                v-model="objForm_initiative.fyzje"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :span="20">
          <el-col :span="10">
            <el-form-item label="收到金额(不含费用):">
              <el-input
                style="width: 160px"
                v-model="objForm_initiative.sdje"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="诉讼费用总额:">
              <el-input
                v-model="objForm_initiative.ssfyze"
                placeholder=""
                style="width: 170px"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :span="20">
          <el-col :span="10">
            <el-form-item label="拖欠总本息金额：">
              <el-input
                style="width: 160px"
                v-model="objForm_initiative.zjhm"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :span="20">
          <el-col :span="10">
            <el-form-item label="本次总计还款金额：">
              <el-input
                style="width: 160px"
                v-model="objForm_initiative.bczjhkje"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :span="20">
          <el-col :span="10">
            <el-form-item label="剩余期数：">
              <el-input
                style="width: 160px"
                v-model="objForm_initiative.syqs"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

      <br />
      <br />
      <br />
      <span style="color: black; font-size: 20px; padding-top: 0; float: left"
        >费用信息</span
      >
      <el-table
        :data="costInfo"
        title="费用信息列表（主动还款）"
        border
        height="300"
        stripe="true"
        style="width: 150%"
      >
        <!-- <el-table-column type="selection"  /> -->
        <el-table-column
          prop="fyms"
          label="费用描述"
          width="180"
          align="center"
        />
        <el-table-column
          prop="sfbs"
          label="收付标识"
          width="100"
          align="center"
        />
        <el-table-column
          prop="jzje"
          label="基准金额"
          width="120"
          align="center"
        />
        <el-table-column prop="flv" label="费率" width="80" align="center" />
        <el-table-column
          prop="fyje"
          label="费用金额"
          width="120"
          align="center"
        />
        <el-table-column
          prop="jmje"
          label="减免金额"
          width="120"
          align="center"
        />
        <el-table-column
          prop="sjje"
          label="实际金额"
          width="120"
          align="center"
        />
        <el-table-column
          prop="jsrq"
          label="结算日期"
          width="120"
          align="center"
        />
        <el-table-column
          prop="fyly"
          label="费用来源"
          width="120"
          align="center"
        />
      </el-table>
      <div style="float: left; padding-top: 10px">
        <el-button
          type="primary"
          @click="handleRepaymentScheduleDialogShow"
          size="large"
          >还款计划</el-button
        >
        <!-- <el-button  type="primary"  @click="restAll" size="large">保存</el-button> -->
        <el-button type="primary" @click="submit" size="large">提交</el-button>
        <el-button type="info" @click="shut" size="large">关闭</el-button>
      </div>
    </div>

    <div class="repaymentInitiative" v-if="show_repaymentScheduled1">
      <!-- 预约还款页面 -->
      <span style="color: black; font-size: 20px; padding-top: 0; float: left"
        >基本信息</span
      >
      <el-divider />

      <el-form
        label-width="140px"
        label-position="right"
        style="padding-left: 10px"
      >
        <el-row :span="20">
          <el-col :span="10">
            <el-form-item label="贷款合同号：">
              <el-input
                style="width: 160px"
                v-model="objForm_scheduled.contNo"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="贷款借据号：">
              <el-input
                style="width: 160px"
                v-model="objForm_scheduled.loanNo"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :span="20">
          <el-col :span="10">
            <el-form-item label="客户姓名：">
              <el-input
                style="width: 160px"
                v-model="objForm_scheduled.custName"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="证件类型：">
              <el-select
                v-model="objForm_scheduled.idTyp"
                placeholder=""
                style="width: 160px"
              >
                <el-option
                  v-for="item in zjlx2Options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :span="20">
          <el-col :span="10">
            <el-form-item label="证件号码：">
              <el-input
                style="width: 160px"
                v-model="objForm_scheduled.idNo"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="客户开户行：">
              <el-input
                style="width: 160px"
                v-model="objForm_scheduled.khkhh"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :span="20">
          <el-col :span="10">
            <el-form-item label="还款卡号：">
              <el-input
                style="width: 160px"
                v-model="objForm_scheduled.acctNo"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="客户还款日：">
              <el-input
                style="width: 160px"
                v-model="objForm_scheduled.khhkr"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :span="20">
          <el-col :span="10">
            <el-form-item label="客户贷款状态：">
              <el-select
                v-model="objForm_scheduled.khdkzt"
                placeholder=""
                style="width: 160px"
              >
                <el-option
                  v-for="item in khdkztOptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="放款金额：">
              <el-input
                style="width: 160px"
                v-model="objForm_scheduled.origPrcped"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :span="20">
          <el-col :span="10">
            <el-form-item label="剩余本金：">
              <el-input
                style="width: 160px"
                v-model="objForm_scheduled.sybj"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="执行年利率：">
              <el-input
                style="width: 160px"
                v-model="objForm_scheduled.loanIntRate"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :span="20">
          <el-col :span="10">
            <el-form-item label="溢缴款余额：">
              <el-input
                style="width: 160px"
                v-model="objForm_scheduled.yjkye"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

      <span style="color: black; font-size: 20px; padding-top: 0; float: left"
        >预约还款信息</span
      >
      <el-divider />
      <el-form
        label-width="140px"
        label-position="right"
        style="padding-left: 10px"
      >
        <el-row :span="20">
          <el-col :span="10">
            <el-form-item label="预约还款日期：">
              <el-date-picker
                v-model="objForm_scheduled.yyhkrq"
                type="date"
                placeholder="选择日期"
                style="width: 160px"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="还款模式：">
              <el-select
                v-model="objForm_scheduled.hkms"
                placeholder=""
                style="width: 160px"
              >
                <el-option
                  v-for="item in hkms2Options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-form-item style="float: left">
            <el-button
              type="primary"
              @click="trial"
              size="large"
              style="margin: 0"
              >预约还款试算</el-button
            >
          </el-form-item>
        </el-row>

        <el-row :span="20">
          <el-col :span="10">
            <el-form-item label="预约还款金额：">
              <el-input
                style="width: 160px"
                v-model="objForm_scheduled.yyhkje"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="提前还款金额：">
              <el-input
                v-model="objForm_scheduled.tqhkje"
                placeholder=""
                style="width: 160px"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :span="20">
          <el-col :span="10">
            <el-form-item label="应还利息：">
              <el-input
                style="width: 160px"
                v-model="objForm_scheduled.yhlx"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :span="20">
          <el-col :span="10">
            <el-form-item label="本次总计还款金额：">
              <el-input
                style="width: 160px"
                v-model="objForm_scheduled.bczjhkje"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :span="20">
          <el-col :span="10">
            <el-form-item label="费用总金额：">
              <el-input
                style="width: 160px"
                v-model="objForm_scheduled.fyzje"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="诉讼费用总金额：">
              <el-input
                style="width: 160px"
                v-model="objForm_scheduled.ssfyzje"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :span="20">
          <el-col :span="10">
            <el-form-item label="拖欠总本息金额：">
              <el-input
                style="width: 160px"
                v-model="objForm_scheduled.tqzbxje"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="剩余期数：">
              <el-input
                style="width: 160px"
                v-model="objForm_scheduled.syqs"
                placeholder=""
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :span="20">
          <el-col :span="10">
            <el-form-item label="提前还款原因：">
              <el-select
                v-model="objForm_scheduled.tqhkyy"
                placeholder=""
                style="width: 160px"
              >
                <el-option
                  v-for="item in tqhkyyOptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :span="20">
          <el-col :span="10">
            <el-form-item label="备注：">
              <el-input
                style="width: 160px"
                v-model="objForm_scheduled.bz"
                placeholder=""
                type="textarea"
                :rows="5"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

      <br />
      <br />
      <br />
      <span style="color: black; font-size: 20px; padding-top: 0; float: left"
        >费用信息</span
      >
      <el-table
        :data="costInfo"
        title="费用信息列表（预约还款）"
        border
        height="300"
        stripe="true"
        style="width: 150%"
      >
        <!-- <el-table-column type="selection"  /> -->
        <el-table-column
          prop="fyms"
          label="费用描述"
          width="180"
          align="center"
        />
        <el-table-column
          prop="sfbs"
          label="收付标识"
          width="100"
          align="center"
        />
        <el-table-column
          prop="jzje"
          label="基准金额"
          width="120"
          align="center"
        />
        <el-table-column prop="flv" label="费率" width="80" align="center" />
        <el-table-column
          prop="fyje"
          label="费用金额"
          width="120"
          align="center"
        />
        <el-table-column
          prop="jmje"
          label="减免金额"
          width="120"
          align="center"
        />
        <el-table-column
          prop="sjje"
          label="实际金额"
          width="120"
          align="center"
        />
        <el-table-column
          prop="jsrq"
          label="结算日期"
          width="120"
          align="center"
        />
        <el-table-column
          prop="fyly"
          label="费用来源"
          width="120"
          align="center"
        />
      </el-table>
      <div style="float: left; padding-top: 10px">
        <el-button
          type="primary"
          @click="handleRepaymentScheduleDialogShow"
          size="large"
          >还款计划</el-button
        >
        <!-- <el-button  type="primary"  @click="restAll" size="large">保存</el-button> -->
        <el-button type="primary" @click="restAll" size="large">提交</el-button>
        <el-button type="info" @click="shut" size="large">关闭</el-button>
      </div>

      <div class="trial">
        <!-- 预约还款试算页面 -->
        <el-dialog
          title="预约还款试算"
          :visible.sync="show_trial"
          :before-close="handleTrialDialogClose"
          width="80%"
          top="4vh"
        >
          <span
            style="color: black; font-size: 20px; padding-top: 0; float: left"
            >试算结果</span
          >
          <el-divider style="color: blue" />
          <el-form label-width="110px" label-position="right">
            <el-row :span="20">
              <el-col :span="12">
                <el-form-item label="应归还本金：">
                  <el-input
                    style="width: 100px"
                    v-model="objForm_trial.yghbj"
                    placeholder=""
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="应归还利息：">
                  <el-input
                    style="width: 100px"
                    v-model="objForm_trial.yghlx"
                    placeholder=""
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row :span="20">
              <el-col :span="12">
                <el-form-item label="罚息：">
                  <el-input
                    style="width: 100px"
                    v-model="objForm_trial.fx"
                    placeholder=""
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="复利">
                  <el-input
                    style="width: 100px"
                    v-model="objForm_trial.fl"
                    placeholder=""
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row :span="20">
              <el-col :span="12">
                <el-form-item label="预约还款本金：">
                  <el-input
                    style="width: 100px"
                    v-model="objForm_trial.yyhkbj"
                    placeholder=""
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="预约还款利息">
                  <el-input
                    style="width: 100px"
                    v-model="objForm_trial.yyhklx"
                    placeholder=""
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
          <div style="height: 80px; padding-top: 30px; padding-left: 360px">
            <el-button
              type="info"
              @click="shut_trial"
              size="large"
              style="float: left"
              >关闭</el-button
            >
          </div>
        </el-dialog>
      </div>
    </div>

    <!-- 还款计划列表 -->
    <el-dialog
      title="还款计划"
      :visible.sync="show_RepaymentSchedule2"
      :before-close="handleRepaymentScheduleDialogClose"
      width="90%"
      top="4vh"
    >
      <div>
        <el-table
          :data="repaymentScheduleData"
          show-summary
          :summary-method="getSummaries"
          style="width: 100%"
        >
          <el-table-column label="还 款 计 划 表" align="center">
            <!-- 序号列 -->
            <el-table-column
              type="index"
              width="50"
              label="期号"
              prop="perdNo"
            ></el-table-column>
            <!-- 其他数据列 -->
            <el-table-column prop="dueDt" label="到期日" align="center" />
            <el-table-column
              prop="psInstmAmt"
              label="期供金额"
              align="center"
            />
            <el-table-column prop="psPrcpAmt" label="本金" align="center" />
            <el-table-column prop="psNormIntAmt" label="利息" align="center" />
            <el-table-column prop="fxfl" label="罚息/复利" align="center" />
            <el-table-column prop="psRemPrcp" label="剩余本金" align="center" />
            <el-table-column prop="setlPrcp" label="已还本金" align="center" />
            <el-table-column
              prop="setlNormInt"
              label="已还利息"
              align="center"
            />
            <el-table-column prop="fyly" label="已还罚息/复利" align="center" />
            <el-table-column prop="yinghze" label="应还总额" align="center" />
            <el-table-column prop="yhze" label="已还总额" align="center" />
            <el-table-column prop="yinghfy" label="应还费用" align="center" />
            <el-table-column
              prop="setlFeeAmt"
              label="已还费用"
              align="center"
            />
            <el-table-column prop="xfjm" label="息费减免" align="center" />
            <el-table-column prop="setlInd" label="结清标志" align="center" />
            <el-table-column prop="yqbz" label="逾期标志" align="center" />
            <el-table-column prop="jqrq" label="结清日期" align="center" />
            <el-table-column prop="jqts" label="结清天数" align="center" />
            <el-table-column
              prop="jqts"
              label="偿还且绩权保留"
              align="center"
            />
            <!-- 总计列 -->
          </el-table-column>
        </el-table>
      </div>
    </el-dialog>
  </div>
</template>
  
  <script>
import {
  queryInfoCMIS100001,
  queryInfoCMIS100003,
  queryInfoCMIS100098,
  rePayCMIS200007,
} from "@/api/hubeixiaojin/queryInfo";

export default {
  name: "proactiveRepayment",
  props: ["data"],
  data() {
    return {
      //repaymentQueryData:[{'custName':'11111'}],
      repaymentQueryData: [],
      // repaymentScheduleData:[
      //   {'qgje':100,'bj':1000,'lx':100,'fxfl':0,'loanOsPrcp':3000},
      //   {'qgje':100,'bj':1000,'lx':100,'fxfl':100,'loanOsPrcp':2000}
      // ],
      repaymentScheduleData: [],
      objForm: {},
      objForm_initiative: {},
      objForm_scheduled: {},
      objForm_trial: {},
      costInfo: [],
      show_query: true,
      show_repaymentInitiative: false,
      show_repaymentScheduled1: false,
      show_trial: false,
      show_RepaymentSchedule2: false,
      total: 0,
      currentPage: 1,
      zjlx1Options: [
        {
          value: "20",
          label: "身份证",
        },
        {
          value: "22",
          label: "护照",
        },
        {
          value: "00",
          label: "员工代码",
        },
        {
          value: "25",
          label: "军官证",
        },
        {
          value: "26",
          label: "士兵证",
        },
        {
          value: "2X",
          label: "其他证件",
        },
        {
          value: "30",
          label: "组织机构代码证",
        },
      ],

      zjlx2Options: [
        {
          value: "20",
          label: "身份证",
        },
        {
          value: "22",
          label: "护照",
        },
        {
          value: "00",
          label: "员工代码",
        },
        {
          value: "25",
          label: "军官证",
        },
        {
          value: "26",
          label: "士兵证",
        },
        {
          value: "2X",
          label: "其他证件",
        },
        {
          value: "30",
          label: "组织机构代码证",
        },
      ],

      khdkztOptions: [
        {
          value: "正常",
          label: "正常",
        },
        {
          value: "",
          label: "",
        },
      ],

      hkms1Options: [
        {
          value: "ER",
          label: "提前还款",
        },
        {
          value: "FS",
          label: "全部还款 ",
        },
      ],

      hkms2Options: [
        {
          value: "ER",
          label: "提前还款",
        },
        {
          value: "FS",
          label: "全部还款 ",
        },
      ],

      tqhkyyOptions: [
        {
          value: "短期资金需求",
          label: "短期资金需求",
        },
        {
          value: "为了再次获得我司贷款",
          label: "为了再次获得我司贷款",
        },
        {
          value: "利息较高，了能不足",
          label: "利息较高，了能不足",
        },
        {
          value: "还款渠道不方便",
          label: "还款渠道不方便",
        },
        {
          value: "贷后服务不满意",
          label: "贷后服务不满意",
        },
        {
          value: "家人要求还款",
          label: "家人要求还款",
        },
        {
          value: "贷款逾期，提前还款",
          label: "贷款逾期，提前还款",
        },
        {
          value: "风险客户，提前还款",
          label: "风险客户，提前还款",
        },
        {
          value: "其他原因",
          label: "其他原因",
        },
      ],
      submitData1: {},
      submitData2: {},
      updateLmPmShd: {},
    };
  },

  created() {
    console.log("主动还款模块初始化：");
    var zjhm = sessionStorage.getItem("idNo"); //身份证号
    this.queryInfo(zjhm);
  },

  watch: {
    $route: function (to, from) {
      console.log("监听【主动还款模块】route变化");
      this.$destroy();
    },
  },

  methods: {
    //还款信息查询:
    queryInfo(str) {
      let self = this;
      console.log("开始查询客户贷款基本信息");
      var param = {
        idNo: str,
      };

      if (this.objForm.idNo > 0) {
        param = {
          idNo: this.objForm.idNo, //身份证号
        };
      }

      if (param.idNo.length > 0) {
        //获取申请流水号列表
        var applSeqList = [];
        queryInfoCMIS100098(param)
          .then((res) => {
            console.log(res);
            if (res.retCode == "200") {
              console.log("调用CMIS100098接口成功");
              applSeqList = res.data;
              //遍历列表，调用CMIS100001接口获取贷款信息
              if (applSeqList.length > 0) {
                queryInfoCMIS100001(applSeqList)
                  .then((res2) => {
                    console.log("res2:");
                    console.log(res2);
                    if (res2.retCode == "200") {
                      console.log("查询成功,赋值repaymentQueryData");
                      self.repaymentQueryData = res2.data;
                    } else {
                      console.log("调用CMIS100001接口失败:");
                      window.globalUiKit.notify(
                        "提示",
                        "未查询到还款信息",
                        "info"
                      );
                    }
                  })
                  .catch((err) => {
                    window.globalUiKit.notify(
                      "提示",
                      "未查询到还款信息",
                      "error"
                    );
                    console.log("调用CMIS100001接口异常:");
                    console.log(err);
                  });
              } else {
                window.globalUiKit.notify(
                  "提示",
                  "未查询到还款信息，请联系管理员",
                  "info"
                );
              }
            } else {
              console.log("调用CMIS100098接口失败:");
            }
          })
          .catch((err) => {
            console.log("调用CMIS100098接口异常:");
            console.log(err);
          });
      } else {
        console.log("还款信息查询 异常：无身份证号");
        window.globalUiKit.notify("提示", "请填写身份证号", "info");
      }
    },

    queryInfoCS(str) {
      let self = this;

      var param = {
        idNo: str,
      };

      console.log("开始查询客户基本信息", param);
      if (this.objForm.idNo.length > 0) {
        // param = this.objForm.idNo;
        param = {
          idNo: this.objForm.idNo, //身份证号
        };
      }
      console.log("还款信息查询 参数：" + param);
      if (param.idNo.length > 0) {
        queryInfoCMIS100098(param)
          .then((res) => {
            // console.log(res);
            if (res.retCode === "200") {
              // console.log("查询还款信息——调用CMIS100098接口成功");
              var applSeqList = res.data;
              // console.log("测试applSeqList:" + applSeqList);
              //遍历列表，调用CMIS100001接口获取贷款信息
              if (applSeqList.length > 0) {
                queryInfoCMIS100001(applSeqList)
                  .then((res2) => {
                    if (res2.retCode == "200") {
                      self.repaymentQueryData = res2.data;
                    } else {
                      console.log("调用CMIS100001接口失败:");
                      window.globalUiKit.notify(
                        "提示",
                        "未查询到还款信息",
                        "info"
                      );
                    }
                  })
                  .catch((err) => {
                    window.globalUiKit.notify(
                      "提示",
                      "未查询到还款信息",
                      "error"
                    );
                    console.log("调用CMIS100001接口异常:");
                    console.log(err);
                  });
              }
            }
          })
          .catch((err) => {
            console.log("调用CMIS100098接口发生异常" + err);
          });
      }
    },

    //主动还款
    handleRepaymentInitiative(index, row) {
      let self = this;
      //调用CMIS100003接口查询还款信息
      var params = {};
      params.loanNo = row.loanNo;
      params.userId = Constants.Agent.agentId; //操作用户
      params.userName = Constants.Agent.agentName; //用户名称
      params.userOrgNo = Constants.Agent.deptGroupCode; //用户机构
      params.enqTyp = "All"; //查询类型
      queryInfoCMIS100003(params)
        .then((res) => {
          console.log("调用CMIS100003");
          console.log(res);
          if (res.retCode === "200") {
            console.log("200");
            self.updateLmPmShd = res.data; //主动还款 还款计划信息
          } else {
            console.log("调用CMIS100003接口查询还款计划列表失败,res:");
            window.globalUiKit.notify(
              "提示",
              "未查询到还款计划,请联系管理员",
              "info"
            );
          }
        })
        .catch((err) => {
          console.log("调用CMIS100003接口发生异常" + err);
          window.globalUiKit.notify(
            "提示",
            "未查询到还款计划,请联系管理员",
            "error"
          );
        });
      this.submitData1 = row;
      //展示主动还款页面，隐藏查询列表页面
      (this.show_query = false),
        (this.show_repaymentInitiative = true),
        (this.show_repaymentScheduled1 = false);
      //基本信息列表：
      this.objForm_initiative.contNo = row.contNo;
      this.objForm_initiative.loanNo = row.loanNo;
      this.objForm_initiative.idTyp = row.idTyp;
      this.objForm_initiative.idNo = row.idNo;
      this.objForm_initiative.custName = row.custName;
      this.objForm_initiative.origPrcped = row.origPrcped;
      this.objForm_initiative.loanOsPrcp = row.loanOsPrcp;
      this.objForm_initiative.loanIntRate = row.loanIntRate;
      //其他待赋值参数：
    },
    //预约还款
    handleRepaymentScheduled(index, row) {
      this.submitData2 = row;
      console.log("???");
      //展示预约还款页面，隐藏查询列表页面
      (this.show_query = false),
        (this.show_repaymentInitiative = false),
        (this.show_repaymentScheduled1 = true);
      //基本信息列表：
      this.objForm_scheduled.contNo = row.contNo;
      this.objForm_scheduled.loanNo = row.loanNo;
      this.objForm_scheduled.idTyp = row.idTyp;
      this.objForm_scheduled.idNo = row.idNo;
      this.objForm_scheduled.custName = row.custName;
      this.objForm_scheduled.origPrcped = row.origPrcped;
      this.objForm_scheduled.loanOsPrcp = row.loanOsPrcp;
      this.objForm_scheduled.loanIntRate = row.loanIntRate;
      //其他待赋值参数：
    },
    //预约还款试算
    trial() {
      this.show_trial = true;
    },
    shut_trial() {
      this.show_trial = false;
      this.objForm_trial = {};
    },

    //提交
    submit() {
      console.log("主动还款，提交:");
      var params = {};
      params.setlSeq = this.submitData1.applSeq; //还款流水号
      params.loanNo = this.submitData1.loanNo; //贷款借据号
      params.contNo = this.submitData1.contNo; //贷款合同编号
      params.custName = this.submitData1.custName; //客户名称
      params.idType = this.submitData1.idTyp; //证件类型
      params.idNo = this.submitData1.idNo; //证件号码
      params.setlCreateUsr = Constants.Agent.agentId; //创建用户
      params.crtOrg = Constants.Agent.deptGroupCode; //创建机构

      params.perdNo = this.updateLmPmShd.perdNo; //期号
      params.dueDt = this.updateLmPmShd.dueDt; //到期日
      params.psInstmAmt = this.updateLmPmShd.psInstmAmt; //期供金额
      params.psPrcpAmt = this.updateLmPmShd.psPrcpAmt; //本金
      params.psNormIntAmt = this.updateLmPmShd.psNormIntAmt; //正常利息
      params.psFeeAmt = this.updateLmPmShd.psFeeAmt; //费用金额
      params.psRemPrcp = this.updateLmPmShd.psRemPrcp; //剩余本金
      params.rtFeeAmt = this.updateLmPmShd.rtFeeAmt; //返费金额

      var currentDate = new Date();
      var year = currentDate.getFullYear();
      var month = currentDate.getMonth() + 1; // 月份从0开始，所以需要加1
      var day = currentDate.getDate();
      var date = year + "-" + month + "-" + day;

      params.setlMode = this.objForm_initiative.hkms; //还款模式
      params.setlTotalFee = this.objForm_initiative.bczjhkje; //本次总计还款金额
      params.setlApplyDt = date; //主动还款申请日期
      params.setlmtDt = ""; //主动还款日期(非必填)
      params.setlRemPrcpPaym = ""; //提前还本金额  (ER模式时必输)
      params.lmPmShdInd = ""; //是否同步还款计划（条件必输）??
      params.lmPmShdVer = ""; //还款计划版本号（放款后需同步还款计划时必输）??
      params.lcClaInd = ""; //溢缴款还款标识(非必输)??
      params.paymPerdCnt = ""; //缩期期数 ??
      params.setlOrigin = ""; //主动还款渠道 ？？
      params.psOdInd = ""; //逾期标识 ？？
      params.settleSts = ""; //结清标识 ？？
      //调用CMIS200007接口
      rePayCMIS200007(params)
        .then((res) => {
          console.log("调用CMIS200007");
          console.log(res);
          if (res.retCode === "200") {
            console.log("200");
            self.updateLmPmShd = res.data; //主动还款 还款计划信息
          } else {
            console.log("调用CMIS200007接口主动还款失败");
            window.globalUiKit.notify(
              "提示",
              "主动还款失败，请联系管理员",
              "info"
            );
          }
        })
        .catch((err) => {
          console.log("调用CMIS200007接口发生异常" + err);
          window.globalUiKit.notify(
            "提示",
            "主动还款失败，请联系管理员",
            "error"
          );
        });
    },
    //关闭
    shut() {
      (this.show_repaymentScheduled1 = false),
        (this.show_repaymentInitiative = false),
        (this.show_query = true);
      (this.objForm_initiative = {}),
        (this.objForm_scheduled = {}),
        (this.costInfo = []);
    },

    //关闭试算弹窗
    handleTrialDialogClose() {},

    //切换当前页
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },
    //切换每页条数
    handleSizeChange_Claim1(val) {},

    getSummaries(param) {
      console.log("22222");
      console.log(param);
      const { columns, data } = param;
      const sums = [];

      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = "总计";
        } else {
          if (
            column.label === "本金" ||
            column.label === "利息" ||
            column.label === "罚息/复利" ||
            column.label === "已还本金" ||
            column.label === "已还利息" ||
            column.label === "已还罚息/复利" ||
            column.label === "应还总额" ||
            column.label === "已还总额" ||
            column.label === "应还费用" ||
            column.label === "已还费用" ||
            column.label === "息费减免"
          ) {
            const values = data.map((item) => Number(item[column.property]));
            if (!values.every((value) => isNaN(value))) {
              sums[index] = values.reduce((prev, curr) => {
                const value = Number(curr);
                if (!isNaN(value)) {
                  return prev + curr;
                } else {
                  return prev;
                }
              }, 0);
            }
          }
        }
      });
      return sums;
    },

    //展示还款计划表：
    handleRepaymentScheduleDialogShow(row) {
      console.log("展示还款计划:");
      this.show_RepaymentSchedule2 = true;

      //调用CMIS100003接口查询还款计划列表
      var params = {};
      params.loanNo = this.costInfo.loanNo;
      params.userId = Constants.Agent.agentId; //操作用户
      params.userName = Constants.Agent.agentName; //用户名称
      params.userOrgNo = Constants.Agent.deptGroupCode; //用户机构
      params.enqTyp = "All"; //查询类型

      queryInfoCMIS100003(params)
        .then((res) => {
          if (res.retCode === "200") {
            console.log("测试CMIS100003 查询 还款列表");
            //还款计划列表：
            this.repaymentScheduleData = res.data.lmPmShdList;
          } else {
            console.log("调用CMIS100003接口查询还款计划列表失败,res:");
            window.globalUiKit.notify(
              "提示",
              "未查询到还款计划,请联系管理员",
              "info"
            );
          }
        })
        .catch((err) => {
          console.log("调用CMIS100003接口发生异常" + err);
          window.globalUiKit.notify(
            "提示",
            "未查询到还款计划,请联系管理员",
            "error"
          );
        });
    },

    //关闭还款计划表
    handleRepaymentScheduleDialogClose() {
      this.show_RepaymentSchedule2 = false;
    },

    restAll() {
      console.log("重置【主动还款】页面数据");
    },
  },
};
</script>
  
  <style scoped>
.repaymentInitiative .el-col-10 {
  width: 300px;
}
</style>
  